package com.tchintech.pay.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.tchintech.pay.R;
import com.tchintech.pay.model.entity.BankAdress;
import com.tchintech.pay.model.entity.PayFees;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by Administrator on 2017/8/25 0025.
 */

public class BankAddressAdapter extends BaseAdapter {
    private List<BankAdress> list;
    private Context context;

    public BankAddressAdapter(Context context, List<BankAdress> list) {
        if (list != null) {
            this.list = list;
        } else {
            this.list = new ArrayList<BankAdress>();
        }
        this.context = context;
        notifyDataSetChanged();
    }

    public List<BankAdress> getList() {
        return this.list;
    }


    public void setList(List<BankAdress> list) {
        if (list != null) {
            this.list .addAll(list);
        } else {
            this.list = new ArrayList<BankAdress>();
        }
        notifyDataSetChanged();
    }

    @Override
    public int getCount() {
        return list.size();
    }

    @Override
    public BankAdress getItem(int position) {
        return list.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View v, ViewGroup parent) {
        ViewHolde vh = null;
        if (v == null) {
            vh = new ViewHolde();
            v = LayoutInflater.from(context).inflate(R.layout.item_bankaddress, null);
            vh.tv_name = (TextView) v.findViewById(R.id.tv_name);
            v.setTag(vh);
        } else {
            vh = (ViewHolde) v.getTag();
        }
        BankAdress bankAdress = list.get(position);
        vh.tv_name.setText(bankAdress.getName());
        return v;
    }

    class ViewHolde {
        TextView tv_name;
    }


}
